home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
impression
/
sssample.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
2KB
|
105 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* sssample -
* Sample an image with a given sample set.
*
* Paul Haeberli - 1988
*/
#include "stdio.h"
#include "ss.h"
#include "texture.h"
#define COLOR 1
#define DIRECTION 2
#define POSITION 4
#define SIZE 8
main(argc,argv)
int argc;
char **argv;
{
sampleset *iss, *oss;
TEXTURE *tm;
int i;
if( argc<4 ) {
fprintf(stderr,"usage: sssample in.ss out.ss inimage [-d] [-s]\n");
exit(1);
}
iss = ssfromfile(argv[1]);
tm = tmopen(argv[3]);
if(!tm) {
fprintf(stderr,"sssample: can't open texture map\n");
exit(1);
}
oss = ssnew();
if(argc>4)
sssampledir(iss,oss,tm);
else
sssamplergb(iss,oss,tm);
sstofile(argv[2],oss);
}
sssampledir(iss,oss,tm)
sampleset *iss, *oss;
TEXTURE *tm;
{
sample *s, *ns;
int imag, bimag;
int size, dir;
vect p, c;
s = iss->head;
while(s) {
ns = sclone(s);
p.x = ns->xpos/(float)POSSCALE;
p.y = ns->ypos/(float)POSSCALE;
tmsample(tm,&p,&c);
dir = (c.x)*255;
if(dir>255)
dir -= 256;
ns->SAMPLE_DIR = dir;
addsample(oss,ns);
s = s->next;
}
}
sssamplergb(iss,oss,tm)
sampleset *iss, *oss;
TEXTURE *tm;
{
sample *s, *ns;
int imag, bimag;
int size;
vect p, c;
s = iss->head;
while(s) {
ns = sclone(s);
p.x = ns->xpos/(float)POSSCALE;
p.y = ns->ypos/(float)POSSCALE;
tmsample(tm,&p,&c);
ns->r = 255*c.x;
ns->g = 255*c.y;
ns->b = 255*c.z;
addsample(oss,ns);
s = s->next;
}
}